{include file = $smarty.const.APPLICATION_PATH|cat:"/application/views/header.html"}
<!--header stop-->
{include file = $smarty.const.APPLICATION_PATH|cat:"/application/views/common/headerusertitle.html"}
<!--header end-->
{literal}
<style>
    .userinput{width: 98%; border: none; text-align: right; padding-right: 15px;}
</style>
{/literal}
<div class="wp_fixed" style="top:48px;">
    <section class="wrap">
        <form method="post" action="/user/addcompany" id="addcompany" >
            <ul class="to-c" style="background:#fff;">
                <li>
                    <span class="">公司名称</span>
                    <span class="fr" style="width: 78%;">
                        <input name="business_name" class="userinput" />
                    </span>
                </li>
                <li>
                    <span class="">公司简称</span>
                    <span class="fr" style="width: 78%;">
                        <input name="business_remarks" class="userinput" />
                    </span>
                </li>
                <li>
                    <span class="">公司电话</span>
                    <span class="fr" style="width: 78%;">
                        <input name="business_phone" class="userinput" />
                    </span>
                </li>
                <li>
                    <span class="">主营品种</span>
                    <span class="fr" style="width: 78%;">
                        <input name="main_variety" class="userinput" placeholder="例如：HDPE,PP"/>
                    </span>
                </li>
                <li>
                    <span class="">联 系 人</span>
                    <span class="fr" style="width: 78%;">
                        <input name="contacts" class="userinput" />
                    </span>
                </li>
                <li>
                    <span class="">联系手机</span>
                    <span class="fr" style="width: 78%;">
                        <input name="mobile" class="userinput" />
                    </span>
                </li>
                <li>
                    <span class="">座机电话</span>
                    <span class="fr" style="width: 78%;">
                        <input name="phone" class="userinput" />
                    </span>
                </li>

                <li>
                    <span class="">　EMAIL</span>
                    <span class="fr" style="width: 78%;">
                        <input name="email" class="userinput" />
                    </span>
                </li>
                <li>
                    <span class="">　　QQ</span>
                    <span class="fr" style="width: 78%;">
                        <input name="qq" class="userinput" />
                    </span>
                </li>
            </ul>
            <p class="sst-btn move-btn"><input type="button" value="保存" class="purchase_w3 btn_em tac"></p>
        </form>
    </section>
    <!--content end-->
</div>
{literal}
<script type="text/javascript">
    $(function(){

        var business_name = $("input[name=business_name]");
        var business_remarks = $("input[name=business_remarks]");
        var business_phone = $("input[name=business_phone]");
        var main_variety = $("input[name=main_variety]");
        var contacts = $("input[name=contacts]");
        var mobile = $("input[name=mobile]");
        var phone = $("input[name=phone]");
        var email = $("input[name=email]");
        var qq = $("input[name=qq]");

        $('.btn_em').click(function(){
            if(
                    nEmpty(business_name,'公司名称不能为空！','公司名称太长或太短,请重新输入！','公司名称不能为数字!')==false||
                    nEmpty(business_remarks,'公司简称不能为空！','公司简称太长或太短,请重新输入！','公司简称不能为数字!')==false||
                    nEmpty(main_variety,'主营产品不能为空！','主营产品太长或太短,请重新输入！','主营产品不能为数字!')==false||
                    nEmpty(contacts,'联系人不能为空！','联系人太长或太短,请重新输入！','联系人不能为数字!')==false||
                    checkSubmitMobil(mobile)==false||
                    checkSubmitQq(qq) == false
                    ){
                return false;
            }else {
                document.getElementById("addcompany").submit();
            }
        });


        function nEmpty(obj,txt1,txt2,txt3){
            Value = obj.val();
            if(Value==''){
                alert(txt1);
                return false;
            }else if(Value.length<2||Value.length>=20){
                alert(txt2);
                return false;
            }else if(!isNaN(obj.val())){
                alert(txt3);
                return false;
            }else{
                return true;
            }
        }

        function checkSubmitMobil(obj){
            if(obj.val()==""){
                alert("手机号码不能为空！");
                return false;
            }
            if(!obj.val().match(/^(?:13\d|15\d|18\d|14\d|17\d)\d{5}(\d{3}|\*{3})$/)){
                alert("手机号码格式不正确！请重新输入！");
                return false;
            }else{
                return true;
            }
        }

        function checkSubmitQq(obj){
            if(obj.val()==""){
                alert("QQ号码不能为空！");
                return false;
            }
            if(isNaN(obj.val())){
                alert("QQ号码格式不正确！请重新输入！");
                return false;
            }else{
                return true;
            }
        }

        business_name.blur(function(){
            nEmpty(business_name,'公司名称不能为空！','公司名称太长或太短,请重新输入！','公司名称不能为数字!');
        });

        business_remarks.blur(function(){
            nEmpty(business_name,'公司名称不能为空！','公司名称太长或太短,请重新输入！','公司名称不能为数字!');
        });

        main_variety.blur(function(){
            nEmpty(business_name,'公司名称不能为空！','公司名称太长或太短,请重新输入！','公司名称不能为数字!');
        });

        contacts.blur(function(){
            nEmpty(business_name,'公司名称不能为空！','公司名称太长或太短,请重新输入！','公司名称不能为数字!');
        });

        mobile.blur(function(){
            checkSubmitMobil(mobile);
        });
        qq.blur(function(){
            checkSubmitQq(qq);
        });

    });
</script>
{/literal}
{include file = $smarty.const.APPLICATION_PATH|cat:"/application/views/footer.html"}
